﻿@{
	ViewBag.Title = "单位管理";
}

@section header{
	<style>
		.current-selected {
			background-color: #C8EBFB !important;
		}

		.sortable-placeholder {
			background-color: #76d1fb !important;
		}

		.sortable-item {
			cursor: move !important;
		}
	</style>
}
@section quickmenu{
	<td style="padding-right: 0px; padding-left: 10px;">
		<span style="cursor: pointer;" title="导出数据库脚本..." @@click="exportSql">
			<i class="icon-sql icon-2x pull-left icon-border crm-bu-style"></i>
		</span>
	</td>
}

@*页面视图列表开始*@
<table class="list_table table100">
	<tbody>
		<tr>
			<td style="">
				<i class="icon-filter pure-icon-bu"></i>视图: <span style="padding-right: 5px; ">
					&nbsp;&nbsp;<a class="cus_markbai tablink" href="javascript:void(0);">所有</a>&nbsp;&nbsp;
				</span>
			</td>
		</tr>
	</tbody>
</table>
@*页面视图列表结束*@
<form id="searchFrm">
	<div style="width:100%;overflow:auto;min-height: 320px;">
		<table style="width:100%;border-collapse:collapse;border:none;table-layout:fixed;">
			<tr>
				<td align="left" style="width:40%;vertical-align:top;overflow:auto;" rowspan="2">
					<table class="lvt small table100">
						<tr>
							<td style="" align="left" nowrap>
								<button class="pure-button pure-button-edit" @@click.prevent="moduleAdd">
									<i class="icon-plus"></i>&nbsp;新增模块
								</button>
								&nbsp;
								<button class="pure-button pure-button-danger" @@click.prevent="moduleBatchDelete">
									<i class="icon-trash"></i>&nbsp;批量删除
								</button>
								&nbsp;
								<span>模块名称</span>
								<input type="text" class="txtBox" style="width: 90px" v-model.trim="moduleConditions.name">
								<span>模块编码</span>
								<input type="text" class="txtBox" style="width: 120px" v-model.trim="moduleConditions.code">
								&nbsp;
								<button class="pure-button pure-button-edit" title="查找" @@click.prevent="moduleRefresh(1)">
									<i class="icon-search"></i>查找
								</button>
								&nbsp;
								<button class="pure-button pure-button-cancel" title="取消" @@click.prevent="moduleReset">
									<i class="icon-rotate-left"></i>重置
								</button>
							</td>
						</tr>
					</table>
					<table id="tblModuleList" class="crm-table table100 padding2 sortable" cellspacing="1" cellpadding="3" style="table-layout:fixed;">
						<caption v-show="moduleData.list.length==0">
							暂无数据
						</caption>
						<tr class="windLayerHead">
							<td style="width: 20px;text-align:center;">
								<input type="checkbox" name="selectall" @@click="moduleToggle($event)" v-model="moduleData.checked" />
							</td>
							<td style="width:80px;">
								<a class='listFormHeaderLinks' @@click="moduleSort('Name')">
									模块名称
									<i :class="{'icon-caret-up':moduleSortColumn.order=='asc','icon-caret-down':moduleSortColumn.order=='desc'}" v-if="'Name'==moduleSortColumn.name"></i>
								</a>
							</td>
							<td style="width:220px;">
								<a class='listFormHeaderLinks' @@click="moduleSort('Code')">
									模块编码
									<i :class="{'icon-caret-up':moduleSortColumn.order=='asc','icon-caret-down':moduleSortColumn.order=='desc'}" v-if="'Code'==moduleSortColumn.name"></i>
								</a>
							</td>
							<td style="width:60px;text-align:center;">
								图标
							</td>
							<td style="width:60px;text-align:center;">
								<a class='listFormHeaderLinks' @@click="moduleSort('Sort')">
									排序值
									<i :class="{'icon-caret-up':moduleSortColumn.order=='asc','icon-caret-down':moduleSortColumn.order=='desc'}" v-if="'Sort'==moduleSortColumn.name"></i>
								</a>
							</td>
							<td style="width:60px;text-align:center;">
								<a class='listFormHeaderLinks' @@click="moduleSort('Visible')">
									是否可见
									<i :class="{'icon-caret-up':moduleSortColumn.order=='asc','icon-caret-down':moduleSortColumn.order=='desc'}" v-if="'Visible'==moduleSortColumn.name"></i>
								</a>
							</td>
							<td style="width:60px;text-align:center;">
								<a class='listFormHeaderLinks' @@click="moduleSort('Reserved')">
									是否保留
									<i :class="{'icon-caret-up':moduleSortColumn.order=='asc','icon-caret-down':moduleSortColumn.order=='desc'}" v-if="'Reserved'==moduleSortColumn.name"></i>
								</a>
							</td>
							<td nowrap style="width: 45px;">
								操作
							</td>
						</tr>
						<tr v-for="(item,idx) in moduleList" class="sortable-item" :key="item.ID" :data-rid="item.ID" :class="{'crm-table-plural':idx%2==1,'current-selected':currentModule&&currentModule.ID==item.ID}" style="cursor: pointer;" @@click="moduleChange(item)">
							<td style="text-align:center;">
								<input type="checkbox" name="rowid" :value='item.ID' :data-idx="idx" @@click="moduleCheck($event)" :checked="item.CheckedState" />
							</td>
							<td>{{item.Name}}</td>
							<td>{{item.Code}}</td>
							<td style="text-align:center;"><i :class="item.Icon" v-if="item.Icon"></i></td>
							<td style="text-align:center;">{{item.Sort}}</td>
							<td style="text-align:center;"><i class="icon-check" v-if="item.Visible"></i></td>
							<td style="text-align:center;"><i class="icon-check" v-if="item.Reserved"></i></td>
							<td nowrap>
								<i class="icon-edit pure-icon-bu crm-bu-style list-action-btn" title='修改' style="" @@click="moduleEdit(item)"></i>
								<i class="icon-trash pure-icon-bu crm-bu-style list-action-btn" title='删除' style="" @@click="moduleDelete(item)"></i>
							</td>
						</tr>
					</table>
					<table border="0" cellspacing="0" cellpadding="0" class="lvt small table100">
						<tbody>
							<tr>
								<td style="padding-right: 5px;">
									<vue-pagination :total="moduleData.total" :psize="moduleData.psize" :pnum="moduleData.pnum" @@change="modulePageChangeHandler"></vue-pagination>
								</td>
							</tr>
						</tbody>
					</table>
				</td>
				<td align="left" style="border-left: 2px dashed #cccccc;width:60%;vertical-align:top;overflow:auto;">
					<table class="lvt small table100">
						<tr>
							<td style="" align="left" nowrap>
								<button class="pure-button pure-button-edit" @@click.prevent="serviceAdd">
									<i class="icon-plus"></i>&nbsp;新增菜单
								</button>
								&nbsp;
								<button class="pure-button pure-button-danger" @@click.prevent="serviceBatchDelete">
									<i class="icon-trash"></i>&nbsp;批量删除
								</button>
								&nbsp;
								<span>菜单名称</span>
								<input type="text" class="txtBox" style="width: 90px" v-model.trim="serviceConditions.name">
								<span>菜单编码</span>
								<input type="text" class="txtBox" style="width: 120px" v-model.trim="serviceConditions.code">
								&nbsp;
								<button class="pure-button pure-button-edit" title="查找" @@click.prevent="serviceRefresh(1)">
									<i class="icon-search"></i>查找
								</button>
								&nbsp;
								<button class="pure-button pure-button-cancel" title="取消" @@click.prevent="serviceReset">
									<i class="icon-rotate-left"></i>重置
								</button>
							</td>
						</tr>
					</table>
					<table id="tblServiceList" class="crm-table table100 padding2" cellspacing="1" cellpadding="3">
						<caption v-show="serviceData.list.length==0">
							暂无数据
						</caption>
						<tr class="windLayerHead">
							<td style="width: 20px;text-align:center;">
								<input type="checkbox" name="selectall" @@click="serviceToggle($event)" v-model="serviceData.checked" />
							</td>
							<td style="width:120px;">
								<a class='listFormHeaderLinks' @@click="serviceSort('Name')">
									菜单名称
									<i :class="{'icon-caret-up':serviceSortColumn.order=='asc','icon-caret-down':serviceSortColumn.order=='desc'}" v-if="'Name'==serviceSortColumn.name"></i>
								</a>
							</td>
							<td style="width:120px;">
								<a class='listFormHeaderLinks' @@click="serviceSort('Code')">
									菜单编码
									<i :class="{'icon-caret-up':serviceSortColumn.order=='asc','icon-caret-down':serviceSortColumn.order=='desc'}" v-if="'Code'==serviceSortColumn.name"></i>
								</a>
							</td>
							<td style="width:120px;">
								菜单链接
							</td>
							<td style="width:60px;text-align:center;">
								图标
							</td>
							<td style="width:60px;text-align:center;">
								<a class='listFormHeaderLinks' @@click="serviceSort('Sort')">
									排序值
									<i :class="{'icon-caret-up':serviceSortColumn.order=='asc','icon-caret-down':serviceSortColumn.order=='desc'}" v-if="'Sort'==serviceSortColumn.name"></i>
								</a>
							</td>
							<td style="width:60px;text-align:center;">
								<a class='listFormHeaderLinks' @@click="serviceSort('Visible')">
									是否可见
									<i :class="{'icon-caret-up':serviceSortColumn.order=='asc','icon-caret-down':serviceSortColumn.order=='desc'}" v-if="'Visible'==serviceSortColumn.name"></i>
								</a>
							</td>
							<td style="width:60px;text-align:center;">
								<a class='listFormHeaderLinks' @@click="serviceSort('Reserved')">
									是否保留
									<i :class="{'icon-caret-up':serviceSortColumn.order=='asc','icon-caret-down':serviceSortColumn.order=='desc'}" v-if="'Reserved'==serviceSortColumn.name"></i>
								</a>
							</td>
							<td nowrap style="width: 45px;">
								操作
							</td>
						</tr>
						<tr v-for="(item,idx) in serviceList" :key="item.ID" class="sortable-item" :data-rid="item.ID" :class="{'crm-table-plural':idx%2==1,'current-selected':currentService&&currentService.ID==item.ID}" style="cursor: pointer;" @@click="serviceChange(item)">
							<td style="text-align:center;">
								<input type="checkbox" name="rowid" :value='item.ID' :data-idx="idx" @@click="serviceCheck($event)" :checked="item.CheckedState" />
							</td>
							<td>{{item.Name}}</td>
							<td>{{item.Code}}</td>
							<td>{{item.Url}}</td>
							<td style="text-align:center;"><i :class="item.Icon" v-if="item.Icon"></i></td>
							<td style="text-align:center;">{{item.Sort}}</td>
							<td style="text-align:center;"><i class="icon-check" v-if="item.Visible"></i></td>
							<td style="text-align:center;"><i class="icon-check" v-if="item.Reserved"></i></td>
							<td nowrap>
								<i class="icon-batchadd pure-icon-bu crm-bu-style list-action-btn" title='快速添加常用功能' style="" @@click="batchAddAction(item)"></i>
								<i class="icon-edit pure-icon-bu crm-bu-style list-action-btn" title='修改' style="" @@click="serviceEdit(item)"></i>
								<i class="icon-trash pure-icon-bu crm-bu-style list-action-btn" title='删除' style="" @@click="serviceDelete(item)"></i>
							</td>
						</tr>
					</table>
					<table border="0" cellspacing="0" cellpadding="0" class="lvt small table100">
						<tbody>
							<tr>
								<td style="padding-right: 5px;">
									<vue-pagination :total="serviceData.total" :psize="serviceData.psize" :pnum="serviceData.pnum" @@change="servicePageChangeHandler"></vue-pagination>
								</td>
							</tr>
						</tbody>
					</table>
				</td>
			</tr>
			<tr>
				<td style="border-top: 2px dashed #cccccc;vertical-align: top;overflow:auto;">
					<table class="lvt small table100">
						<tr>
							<td style="" align="left" nowrap>
								<button class="pure-button pure-button-edit" @@click.prevent="actionAdd">
									<i class="icon-plus"></i>&nbsp;新增功能
								</button>
								&nbsp;
								<button class="pure-button pure-button-danger" @@click.prevent="actionBatchDelete">
									<i class="icon-trash"></i>&nbsp;批量删除
								</button>
								&nbsp;
								<span>功能名称</span>
								<input type="text" class="txtBox" style="width: 90px" v-model.trim="actionConditions.name">
								<span>功能编码</span>
								<input type="text" class="txtBox" style="width: 120px" v-model.trim="actionConditions.code">
								&nbsp;
								<button class="pure-button pure-button-edit" title="查找" @@click.prevent="actionRefresh(1)">
									<i class="icon-search"></i>查找
								</button>
								&nbsp;
								<button class="pure-button pure-button-cancel" title="取消" @@click.prevent="actionReset">
									<i class="icon-rotate-left"></i>重置
								</button>
							</td>
						</tr>
					</table>
					<table id="tblActionList" class="crm-table table100 padding2" cellspacing="1" cellpadding="3">
						<caption v-show="actionData.list.length==0">
							暂无数据
						</caption>
						<tr class="windLayerHead">
							<td style="width: 20px;text-align:center;">
								<input type="checkbox" name="selectall" @@click="actionToggle($event)" v-model="actionData.checked" />
							</td>
							<td style="width:120px;">
								<a class='listFormHeaderLinks' @@click="actionSort('Name')">
									功能名称
									<i :class="{'icon-caret-up':actionSortColumn.order=='asc','icon-caret-down':actionSortColumn.order=='desc'}" v-if="'Name'==actionSortColumn.name"></i>
								</a>
							</td>
							<td style="width:120px;">
								<a class='listFormHeaderLinks' @@click="actionSort('Code')">
									功能编码
									<i :class="{'icon-caret-up':actionSortColumn.order=='asc','icon-caret-down':actionSortColumn.order=='desc'}" v-if="'Code'==actionSortColumn.name"></i>
								</a>
							</td>
							<td style="width:120px;">
								功能链接
							</td>
							<td style="width:120px;">
								功能说明
							</td>
							<td style="width:60px;text-align:center;">
								图标
							</td>
							<td style="width:60px;text-align:center;">
								<a class='listFormHeaderLinks' @@click="actionSort('Sort')">
									排序值
									<i :class="{'icon-caret-up':actionSortColumn.order=='asc','icon-caret-down':actionSortColumn.order=='desc'}" v-if="'Sort'==actionSortColumn.name"></i>
								</a>
							</td>
							<td style="width:60px;text-align:center;">
								<a class='listFormHeaderLinks' @@click="actionSort('Visible')">
									是否可见
									<i :class="{'icon-caret-up':actionSortColumn.order=='asc','icon-caret-down':actionSortColumn.order=='desc'}" v-if="'Visible'==actionSortColumn.name"></i>
								</a>
							</td>
							<td style="width:60px;text-align:center;">
								<a class='listFormHeaderLinks' @@click="actionSort('Reserved')">
									是否保留
									<i :class="{'icon-caret-up':actionSortColumn.order=='asc','icon-caret-down':actionSortColumn.order=='desc'}" v-if="'Reserved'==actionSortColumn.name"></i>
								</a>
							</td>
							<td nowrap style="width: 45px;">
								操作
							</td>
						</tr>
						<tr v-for="(item,idx) in actionList" :key="item.ID" class="sortable-item" :data-rid="item.ID" :class="{'crm-table-plural':idx%2==1,'current-selected':currentAction&&currentAction.ID==item.ID}" style="cursor: pointer;" @@click="actionChange(item)">
							<td style="text-align:center;">
								<input type="checkbox" name="rowid" :value='item.ID' :data-idx="idx" @@click="actionCheck($event)" :checked="item.CheckedState" />
							</td>
							<td>{{item.Name}}</td>
							<td>{{item.Code}}</td>
							<td>{{item.Url}}</td>
							<td>{{item.Comment}}</td>
							<td style="text-align:center;"><i :class="item.Icon" v-if="item.Icon"></i></td>
							<td style="text-align:center;">{{item.Sort}}</td>
							<td style="text-align:center;"><i class="icon-check" v-if="item.Visible"></i></td>
							<td style="text-align:center;"><i class="icon-check" v-if="item.Reserved"></i></td>
							<td nowrap>
								<i class="icon-edit pure-icon-bu crm-bu-style list-action-btn" title='修改' style="" @@click="actionEdit(item)"></i>
								<i class="icon-trash pure-icon-bu crm-bu-style list-action-btn" title='删除' style="" @@click="actionDelete(item)"></i>
							</td>
						</tr>
					</table>
					<table border="0" cellspacing="0" cellpadding="0" class="lvt small table100">
						<tbody>
							<tr>
								<td style="padding-right: 5px;">
									<vue-pagination :total="actionData.total" :psize="actionData.psize" :pnum="actionData.pnum" @@change="actionPageChangeHandler"></vue-pagination>
								</td>
							</tr>
						</tbody>
					</table>
				</td>
			</tr>
		</table>
	</div>
</form>
@*生成列表操作*@
<div id="moduleEditDiv" class="windLayerDiv" style="display: none;">
	<table class="windLayerHeadingULine table100" cellpadding="3" cellspacing="0">
		<tr class="windLayerHeadingTr">
			<td width="80%" style="cursor: move;" class="windLayerHeading" align="left">
				编辑模块信息
			</td>
			<td align="right">
				<input class="windLayerBtclose" type="button" title="关闭" onclick="popClose();">&nbsp;&nbsp;
			</td>
		</tr>
	</table>
	<form id="moduleEditFrm">
		<table style="background-color: rgb(234, 234, 234);width:100%;" class="small" border="0" cellpadding="3" cellspacing="1">
			<tr class="detail-content-heading" style="height: 28px;">
				<td colspan="2">
					<b>&nbsp;&nbsp;基本信息</b>
				</td>
			</tr>
			<tr bgcolor="white" height="25px;">
				<td class="windLayerTitle" align="right" width="30%">
					<span style="color: #f00;">*</span>模块名称
				</td>
				<td class="windLayerInfo" align="left" width="70%">
					<input type="text" v-model.trim="currentModule.Name" class="detailedViewTextBox validate[required]"
						   style="width: 90%;" />
				</td>
			</tr>
			<tr bgcolor="white" height="25px;">
				<td class="windLayerTitle" align="right">
					模块编码
				</td>
				<td class="windLayerInfo" align="left">
					<input type="text" v-model.trim="currentModule.Code" class="detailedViewTextBox" style="width: 90%;" />
				</td>
			</tr>
			<tr bgcolor="white" height="25px;">
				<td class="windLayerTitle" align="right">
					模块图标
				</td>
				<td class="windLayerInfo" align="left">
					<i :class="currentModule.Icon" v-if="currentModule.Icon"></i>
					<input type="text" v-model.trim="currentModule.Icon" class="detailedViewTextBox input-sm" style="width: 30%;" />
					<button title="选择" onclick="openPopIcon('popModuleIconCallback',this);return false;" class="pure-button pure-button-edit pure-icon-bu" style="">
						<i class="icon-search"></i>
					</button>
					<button title="清除" onclick="popModuleIconClear();return false;" class="pure-button pure-button-approve pure-icon-bu" style="">
						<i class="icon-remove"></i>
					</button>
				</td>
			</tr>
			<tr bgcolor="white" height="25px;">
				<td class="windLayerTitle" align="right">
					排序
				</td>
				<td class="windLayerInfo" align="left">
					<input type="number" v-model="currentModule.Sort" value="" class="detailedViewTextBox" style="width: 90%;" />
				</td>
			</tr>
			<tr bgcolor="white" height="25px;">
				<td class="detail-content-label">
					是否可见
				</td>
				<td class="detail-content-info">
					<input type="checkbox" class="" v-model="currentModule.Visible" />
				</td>
			</tr>
			<tr bgcolor="white" height="25px;">
				<td class="detail-content-label">
					是否系统保留
				</td>
				<td class="detail-content-info">
					<input type="checkbox" class="" v-model="currentModule.Reserved" />
				</td>
			</tr>
			<tr bgcolor="white" height="40px;">
				<td colspan="2" align="center">
					<button type="button" class="pure-button pure-button-success save" onclick="$('#moduleEditFrm').submit();">
						<i class="icon-check"></i>保存
					</button>
					&nbsp;&nbsp;&nbsp;&nbsp;
					<button type="button" class="pure-button pure-button-cancel" onclick="popClose();return false;">
						<i class="icon-reply"></i>取消
					</button>
					&nbsp;
				</td>
			</tr>
		</table>
	</form>
	<div class="windLayerFoot">
		&nbsp;
	</div>
	<div class="windLayerCorner">
		&nbsp;
	</div>
</div>
<div id="serviceEditDiv" class="windLayerDiv" style="display: none;">
	<table class="windLayerHeadingULine table100" cellpadding="3" cellspacing="0">
		<tr class="windLayerHeadingTr">
			<td width="80%" style="cursor: move;" class="windLayerHeading" align="left">
				编辑菜单信息
			</td>
			<td align="right">
				<input class="windLayerBtclose" type="button" title="关闭" onclick="popClose();">&nbsp;&nbsp;
			</td>
		</tr>
	</table>
	<form id="serviceEditFrm">
		<table style="background-color: rgb(234, 234, 234);width:100%;" class="small" border="0" cellpadding="3" cellspacing="1">
			<tr class="detail-content-heading" style="height: 28px;">
				<td colspan="2">
					<b>&nbsp;&nbsp;基本信息</b>
				</td>
			</tr>
			<tr bgcolor="white" height="25px;">
				<td class="windLayerTitle" align="right">
					所属模块
				</td>
				<td class="windLayerInfo" align="left">
					{{currentService.ModuleName}}
				</td>
			</tr>
			<tr bgcolor="white" height="25px;">
				<td class="windLayerTitle" align="right" width="30%">
					<span style="color: #f00;">*</span>菜单名称
				</td>
				<td class="windLayerInfo" align="left" width="70%">
					<input type="text" v-model.trim="currentService.Name" class="detailedViewTextBox validate[required]"
						   style="width: 90%;" />
				</td>
			</tr>
			<tr bgcolor="white" height="25px;">
				<td class="windLayerTitle" align="right">
					菜单编码
				</td>
				<td class="windLayerInfo" align="left">
					<input type="text" v-model.trim="currentService.Code" class="detailedViewTextBox" style="width: 90%;" />
				</td>
			</tr>
			<tr bgcolor="white" height="25px;">
				<td class="windLayerTitle" align="right">
					菜单链接
				</td>
				<td class="windLayerInfo" align="left">
					<input type="text" v-model.trim="currentService.Url" class="detailedViewTextBox" style="width: 90%;" />
				</td>
			</tr>
			<tr bgcolor="white" height="25px;">
				<td class="windLayerTitle" align="right">
					菜单图标
				</td>
				<td class="windLayerInfo" align="left">
					<i :class="currentService.Icon" v-if="currentService.Icon"></i>
					<input type="text" v-model.trim="currentService.Icon" class="detailedViewTextBox input-sm" style="width: 30%;" />
					<button title="选择" onclick="openPopIcon('popServiceIconCallback',this);return false;" class="pure-button pure-button-edit pure-icon-bu" style="">
						<i class="icon-search"></i>
					</button>
					<button title="清除" onclick="popServiceIconClear();return false;" class="pure-button pure-button-approve pure-icon-bu" style="">
						<i class="icon-remove"></i>
					</button>
				</td>
			</tr>
			<tr bgcolor="white" height="25px;">
				<td class="windLayerTitle" align="right">
					排序
				</td>
				<td class="windLayerInfo" align="left">
					<input type="number" v-model="currentService.Sort" value="" class="detailedViewTextBox" style="width: 90%;" />
				</td>
			</tr>
			<tr bgcolor="white" height="25px;">
				<td class="detail-content-label">
					是否可见
				</td>
				<td class="detail-content-info">
					<input type="checkbox" class="" v-model="currentService.Visible" />
				</td>
			</tr>
			<tr bgcolor="white" height="40px;">
				<td colspan="2" align="center">
					<button type="button" class="pure-button pure-button-success save" onclick="$('#serviceEditFrm').submit();">
						<i class="icon-check"></i>保存
					</button>
					&nbsp;&nbsp;&nbsp;&nbsp;
					<button type="button" class="pure-button pure-button-cancel" onclick="popClose();return false;">
						<i class="icon-reply"></i>取消
					</button>
					&nbsp;
				</td>
			</tr>
		</table>
	</form>
	<div class="windLayerFoot">
		&nbsp;
	</div>
	<div class="windLayerCorner">
		&nbsp;
	</div>
</div>
<div id="actionEditDiv" class="windLayerDiv" style="display: none;">
	<table class="windLayerHeadingULine table100" cellpadding="3" cellspacing="0">
		<tr class="windLayerHeadingTr">
			<td width="80%" style="cursor: move;" class="windLayerHeading" align="left">
				编辑功能信息
			</td>
			<td align="right">
				<input class="windLayerBtclose" type="button" title="关闭" onclick="popClose();">&nbsp;&nbsp;
			</td>
		</tr>
	</table>
	<form id="actionEditFrm">
		<table style="background-color: rgb(234, 234, 234);width:100%;" class="small" border="0" cellpadding="3" cellspacing="1">
			<tr class="detail-content-heading" style="height: 28px;">
				<td colspan="2">
					<b>&nbsp;&nbsp;基本信息</b>
				</td>
			</tr>
			<tr bgcolor="white" height="25px;">
				<td class="windLayerTitle" align="right">
					所属菜单
				</td>
				<td class="windLayerInfo" align="left">
					{{currentAction.ServiceName}}
				</td>
			</tr>
			<tr bgcolor="white" height="25px;">
				<td class="windLayerTitle" align="right" width="30%">
					<span style="color: #f00;">*</span>功能名称
				</td>
				<td class="windLayerInfo" align="left" width="70%">
					<input type="text" v-model.trim="currentAction.Name" class="detailedViewTextBox validate[required]"
						   style="width: 90%;" />
				</td>
			</tr>
			<tr bgcolor="white" height="25px;">
				<td class="windLayerTitle" align="right">
					功能编码
				</td>
				<td class="windLayerInfo" align="left">
					<input type="text" v-model.trim="currentAction.Code" class="detailedViewTextBox" style="width: 90%;" />
				</td>
			</tr>
			<tr bgcolor="white" height="25px;">
				<td class="windLayerTitle" align="right">
					功能链接
				</td>
				<td class="windLayerInfo" align="left">
					<input type="text" v-model.trim="currentAction.Url" class="detailedViewTextBox" style="width: 90%;" />
				</td>
			</tr>
			<tr bgcolor="white" height="25px;">
				<td class="windLayerTitle" align="right">
					功能说明
				</td>
				<td class="windLayerInfo" align="left">
					<input type="text" v-model.trim="currentAction.Comment" class="detailedViewTextBox" style="width: 90%;" />
				</td>
			</tr>
			<tr bgcolor="white" height="25px;">
				<td class="windLayerTitle" align="right">
					功能图标
				</td>
				<td class="windLayerInfo" align="left">
					<i :class="currentAction.Icon" v-if="currentAction.Icon"></i>
					<input type="text" v-model.trim="currentAction.Icon" class="detailedViewTextBox input-sm" style="width: 30%;" />
					<button title="选择" onclick="openPopIcon('popActionIconCallback',this);return false;" class="pure-button pure-button-edit pure-icon-bu" style="">
						<i class="icon-search"></i>
					</button>
					<button title="清除" onclick="popActionIconClear();return false;" class="pure-button pure-button-approve pure-icon-bu" style="">
						<i class="icon-remove"></i>
					</button>
				</td>
			</tr>
			<tr bgcolor="white" height="25px;">
				<td class="windLayerTitle" align="right">
					排序
				</td>
				<td class="windLayerInfo" align="left">
					<input type="number" v-model="currentAction.Sort" value="" class="detailedViewTextBox" style="width: 90%;" />
				</td>
			</tr>
			<tr bgcolor="white" height="25px;">
				<td class="detail-content-label">
					是否可见
				</td>
				<td class="detail-content-info">
					<input type="checkbox" class="" v-model="currentAction.Visible" />
				</td>
			</tr>
			<tr bgcolor="white" height="40px;">
				<td colspan="2" align="center">
					<button type="button" class="pure-button pure-button-success save" onclick="$('#actionEditFrm').submit();">
						<i class="icon-check"></i>保存
					</button>
					&nbsp;&nbsp;&nbsp;&nbsp;
					<button type="button" class="pure-button pure-button-cancel" onclick="popClose();return false;">
						<i class="icon-reply"></i>取消
					</button>
					&nbsp;
				</td>
			</tr>
		</table>
	</form>
	<div class="windLayerFoot">
		&nbsp;
	</div>
	<div class="windLayerCorner">
		&nbsp;
	</div>
</div>
<div id="batchAddActionDiv" class="windLayerDiv" style="display: none;">
	<table class="windLayerHeadingULine table100" cellpadding="3" cellspacing="0">
		<tr class="windLayerHeadingTr">
			<td width="80%" style="cursor: move;" class="windLayerHeading" align="left">
				批量添加常用功能信息
			</td>
			<td align="right">
				<input class="windLayerBtclose" type="button" title="关闭" onclick="popClose();">&nbsp;&nbsp;
			</td>
		</tr>
	</table>
	<form id="batchAddActionFrm">
		<table style="background-color: rgb(234, 234, 234);width:100%;" class="small" border="0" cellpadding="3" cellspacing="1">
			<tr class="detail-content-heading" style="height: 28px;">
				<td colspan="5">
					<b>&nbsp;&nbsp;选择功能</b>
				</td>
			</tr>
			<tr bgcolor="white" height="25px;">
				<td class="windLayerTitle" align="right">
					所属菜单
				</td>
				<td class="windLayerInfo" align="left" colspan="4">
					{{currentAction.ServiceName}}
				</td>
			</tr>
			<tr bgcolor="white" height="25px;">
				<td class="windLayerTitle" align="right" rowspan="6" width="30%">
					<span style="color: #f00;">*</span>选择功能
				</td>
				<td class="windLayerInfo" style="width:70px;text-align:center;">
					<input type="checkbox" name="list" />
				</td>
				<td class="windLayerInfo" style="width:70px;text-align:center;">
					名称
				</td>
				<td class="windLayerInfo" style="width:70px;text-align:center;">
					编码
				</td>
				<td class="windLayerInfo" style="text-align:center;">
					说明
				</td>
			</tr>
			<tr bgcolor="white" height="25px;">
				<td class="windLayerInfo" style="text-align:center;">
					列表<input type="checkbox" name="list" />
				</td>
				<td class="windLayerInfo">
					<input type="text" v-model.trim="currentAction.Code" class="detailedViewTextBox" style="" />
				</td>
				<td class="windLayerInfo">
					<input type="text" v-model.trim="currentAction.Code" class="detailedViewTextBox" style="" />
				</td>
				<td class="windLayerInfo">
					<input type="text" v-model.trim="currentAction.Code" class="detailedViewTextBox" style="" />
				</td>
			</tr>
			<tr bgcolor="white" height="25px;">
				<td class="windLayerInfo" style="text-align:center;">
					新增<input type="checkbox" name="list" />
				</td>
				<td class="windLayerInfo">
					<input type="text" v-model.trim="currentAction.Code" class="detailedViewTextBox" style="" />
				</td>
				<td class="windLayerInfo">
					<input type="text" v-model.trim="currentAction.Code" class="detailedViewTextBox" style="" />
				</td>
				<td class="windLayerInfo">
					<input type="text" v-model.trim="currentAction.Code" class="detailedViewTextBox" style="" />
				</td>
			</tr>
			<tr bgcolor="white" height="25px;">
				<td class="windLayerInfo" style="text-align:center;">
					修改<input type="checkbox" name="list" />
				</td>
				<td class="windLayerInfo">
					<input type="text" v-model.trim="currentAction.Code" class="detailedViewTextBox" style="" />
				</td>
				<td class="windLayerInfo">
					<input type="text" v-model.trim="currentAction.Code" class="detailedViewTextBox" style="" />
				</td>
				<td class="windLayerInfo">
					<input type="text" v-model.trim="currentAction.Code" class="detailedViewTextBox" style="" />
				</td>
			</tr>
			<tr bgcolor="white" height="25px;">
				<td class="windLayerInfo" style="text-align:center;">
					删除<input type="checkbox" name="list" />
				</td>
				<td class="windLayerInfo">
					<input type="text" v-model.trim="currentAction.Code" class="detailedViewTextBox" style="" />
				</td>
				<td class="windLayerInfo">
					<input type="text" v-model.trim="currentAction.Code" class="detailedViewTextBox" style="" />
				</td>
				<td class="windLayerInfo">
					<input type="text" v-model.trim="currentAction.Code" class="detailedViewTextBox" style="" />
				</td>
			</tr>
			<tr bgcolor="white" height="25px;">
				<td class="windLayerInfo" style="text-align:center;">
					审核<input type="checkbox" name="list" />
				</td>
				<td class="windLayerInfo">
					<input type="text" v-model.trim="currentAction.Code" class="detailedViewTextBox" style="" />
				</td>
				<td class="windLayerInfo">
					<input type="text" v-model.trim="currentAction.Code" class="detailedViewTextBox" style="" />
				</td>
				<td class="windLayerInfo">
					<input type="text" v-model.trim="currentAction.Code" class="detailedViewTextBox" style="" />
				</td>
			</tr>
			<tr bgcolor="white" height="25px;">
				<td class="windLayerTitle" align="right">
					功能编码
				</td>
				<td class="windLayerInfo" align="left" colspan="4">
					<input type="text" v-model.trim="currentAction.Code" class="detailedViewTextBox" style="width: 90%;" />
				</td>
			</tr>
			<tr bgcolor="white" height="40px;">
				<td colspan="5" align="center">
					<button type="button" class="pure-button pure-button-success save" onclick="$('#batchAddActionFrm').submit();">
						<i class="icon-check"></i>保存
					</button>
					&nbsp;&nbsp;&nbsp;&nbsp;
					<button type="button" class="pure-button pure-button-cancel" onclick="popClose();return false;">
						<i class="icon-reply"></i>取消
					</button>
					&nbsp;
				</td>
			</tr>
		</table>
	</form>
	<div class="windLayerFoot">
		&nbsp;
	</div>
	<div class="windLayerCorner">
		&nbsp;
	</div>
</div>
@section footer{
	@*日期必须开始*@
	<script src="~/lib/laydate/laydate.js" asp-append-version="true"></script>
	@*日期必须结束*@
	@*验证开始*@
	<script src="~/lib/validationEngine/jquery.validationEngine.min.js" asp-append-version="true"></script>
	<script src="~/lib/validationEngine/jquery.validationEngine-zh_CN.js" asp-append-version="true"></script>
	<link href="~/lib/validationEngine/validationEngine.jquery.css" rel="stylesheet" asp-append-version="true" />
	@*验证结束*@
	<script src="~/lib/jquery-sortablejs-1.10.1.min.js" asp-append-version="true"></script>
	@*列表相关开始*@
	<script type="text/javascript">
		var moduleConditionsInit = {};//初始查询条件
		var serviceConditionsInit = {};//初始查询条件
		var actionConditionsInit = {};//初始查询条件
		var pageEnumData = {
		};
		var pageData = {
			hideBreadcrumb: false,
			serviceCode: '@(ViewBag.ServiceCode)',
			global: globalData,
			moduleData: {
				checked:false,
				list: [],
				total: 0,
				pnum: 1,
				psize:20,
			},
			serviceData: {
				checked:false,
				list: [],
				total: 0,
				pnum: 1,
				psize:20,
			},
			actionData: {
				checked:false,
				list: [],
				total: 0,
				pnum: 1,
				psize:20,
			},
			moduleConditions: Object.assign({}, moduleConditionsInit),
			serviceConditions: Object.assign({}, serviceConditionsInit),
			actionConditions: Object.assign({}, actionConditionsInit),
			moduleSortColumn: {
				name: "",
				order:""
			},
			serviceSortColumn: {
				name: "",
				order:""
			},
			actionSortColumn: {
				name: "",
				order:""
			},
			currentModule: {},
			currentService: {},
			currentAction: {},

		};

		var pageApp = new Vue({
			el: '#app',
			data: pageData,
			mounted: function () {
				this.moduleRefresh();
			},
			methods: {
				moduleChange: function (v) {
					this.currentModule = v || {};
					this.serviceRefresh(1);
				},
				serviceChange: function (v) {
					this.currentService = v || {};
					this.actionRefresh(1);
				},
				actionChange: function (v) {
					this.currentAction = v || {};
				},
				modulePageChangeHandler: function (args) {
					this.moduleRefresh(args.pnum, args.psize)
				},
				servicePageChangeHandler: function (args) {
					this.serviceRefresh(args.pnum, args.psize)
				},
				actionPageChangeHandler: function (args) {
					this.actionRefresh(args.pnum, args.psize)
				},
				moduleRefresh: function (pageNum, pageSize) {
					var _params = Object.assign({}, {
						pnum: pageNum || this.moduleData.pnum,
						psize: pageSize || this.moduleData.psize,
						sortorder: !this.moduleSortColumn.name ? "" : this.moduleSortColumn.name + "_" + this.moduleSortColumn.order
					}, this.moduleConditions);
					var _this = this;
					utils.ajaxPost('@(Url.Action("Search", "Sys_Module"))', _params, function (resp) {
						var list = resp.data.list.map(function (item) {
							return Object.assign({}, item, {
								CheckedState: false
							});
						});
						_this.moduleChange(list[0]);
						var newData = { list: list, total: resp.data.total, pnum: resp.data.pnum, psize: resp.data.psize ,checked:false};
						_this.moduleData = newData;
						setTimeout(function () {
							initSortableModule();
						}, 100);
					}, function (err) {
					})
				},
				serviceRefresh: function (pageNum, pageSize) {
					var _params = Object.assign({}, {
						pnum: pageNum || this.serviceData.pnum,
						psize: pageSize || this.serviceData.psize,
						moduleid: this.currentModule&&this.currentModule.ID||"0",
						sortorder: !this.serviceSortColumn.name ? "" : this.serviceSortColumn.name + "_" + this.serviceSortColumn.order
					}, this.serviceConditions);
					var _this = this;
					utils.ajaxPost('@(Url.Action("Search", "Sys_ModuleService"))', _params, function (resp) {
						var list = resp.data.list.map(function (item) {
							return Object.assign({}, item, {
								CheckedState: false
							});
						});
						_this.serviceChange(list[0]);
						var newData = { list: list, total: resp.data.total, pnum: resp.data.pnum, psize: resp.data.psize ,checked:false};
						_this.serviceData = newData;
						setTimeout(function () {
							initSortableService();
						}, 100);
					}, function (err) {
					})
				},
				actionRefresh: function (pageNum, pageSize) {
					var _params = Object.assign({}, {
						pnum: pageNum || this.actionData.pnum,
						psize: pageSize || this.actionData.psize,
						serviceid: this.currentService&&this.currentService.ID||"0",
						sortorder: !this.actionSortColumn.name ? "" : this.actionSortColumn.name + "_" + this.actionSortColumn.order
					}, this.actionConditions);
					var _this = this;
					utils.ajaxPost('@(Url.Action("Search", "Sys_ModuleAction"))', _params, function (resp) {
						var list = resp.data.list.map(function (item) {
							return Object.assign({}, item, {
								CheckedState: false
							});
						});
						var newData = { list: list, total: resp.data.total, pnum: resp.data.pnum, psize: resp.data.psize ,checked:false};
						_this.actionData = newData;
						setTimeout(function () {
							initSortableAction();
						}, 100);
					}, function (err) {
					})
				},
				moduleReset: function () {
					this.moduleConditions = Object.assign({}, moduleConditionsInit);
					this.moduleSortColumn = {
						col: "",
						order: ""
					};
					this.moduleRefresh(1);
				},
				serviceReset: function () {
					this.serviceConditions = Object.assign({}, serviceConditionsInit);
					this.serviceSortColumn = {
						col: "",
						order: ""
					};
					this.serviceRefresh(1);
				},
				actionReset: function () {
					this.actionConditions = Object.assign({}, actionConditionsInit);
					this.actionSortColumn = {
						col: "",
						order: ""
					};
					this.actionRefresh(1);
				},
				moduleSort: function (col) {
					if (col != this.moduleSortColumn.name) {
						this.moduleSortColumn.order = "desc";
						this.moduleSortColumn.name = col;
					} else {
						this.moduleSortColumn.order = this.moduleSortColumn.order == "asc" ? "desc" : "asc";
					}
					this.moduleRefresh(1);
				},
				serviceSort: function (col) {
					if (col != this.serviceSortColumn.name) {
						this.serviceSortColumn.order = "desc";
						this.serviceSortColumn.name = col;
					} else {
						this.serviceSortColumn.order = this.serviceSortColumn.order == "asc" ? "desc" : "asc";
					}
					this.serviceRefresh(1);
				},
				actionSort: function (col) {
					if (col != this.actionSortColumn.name) {
						this.actionSortColumn.order = "desc";
						this.actionSortColumn.name = col;
					} else {
						this.actionSortColumn.order = this.actionSortColumn.order == "asc" ? "desc" : "asc";
					}
					this.actionRefresh(1);
				},
				moduleToggle: function (e) {
					var checked = (e.srcElement || e.target).checked;
					this.moduleData.list=this.moduleData.list.map(function (item) {
						return Object.assign({}, item,{
							CheckedState: checked
						});
					});
				},
				moduleCheck: function (e) {
					var obj = e.srcElement || e.target;
					var checked = obj.checked;
					this.moduleData.list[obj.dataset.idx].CheckedState = checked;
				},
				serviceToggle: function (e) {
					var checked = (e.srcElement || e.target).checked;
					this.serviceData.list=this.serviceData.list.map(function (item) {
						return Object.assign({}, item,{
							CheckedState: checked
						});
					});
				},
				serviceCheck: function (e) {
					var obj = e.srcElement || e.target;
					var checked = obj.checked;
					this.serviceData.list[obj.dataset.idx].CheckedState = checked;
				},
				actionToggle: function (e) {
					var checked = (e.srcElement || e.target).checked;
					this.actionData.list=this.actionData.list.map(function (item) {
						return Object.assign({}, item,{
							CheckedState: checked
						});
					});
				},
				actionCheck: function (e) {
					var obj = e.srcElement || e.target;
					var checked = obj.checked;
					this.actionData.list[obj.dataset.idx].CheckedState = checked;
				},
				moduleAdd: function () {
					moduleAdd();
				},
				serviceAdd: function () {
					serviceAdd();
				},
				actionAdd: function () {
					actionAdd();
				},
				moduleEdit: function (item) {
					moduleEdit(item);
				},
				serviceEdit: function (item) {
					serviceEdit(item);
				},
				actionEdit: function (item) {
					actionEdit(item);
				},
				moduleDelete: function (item) {
					var _this = this;
					utils.confirm('确定要删除模块【' + item.Name +'】？', function () {
						utils.ajaxPost('@(Url.Action("Delete","Sys_Module"))', { id: item.ID }, function (resp) {
							utils.success("删除成功");
							_this.moduleRefresh();
						}, function (msg) {
							utils.alert(msg);
						});
					});
				},
				serviceDelete: function (item) {
					var _this = this;
					utils.confirm('确定要删除菜单【' + item.Name +'】？', function () {
						utils.ajaxPost('@(Url.Action("Delete","Sys_ModuleService"))', { id: item.ID }, function (resp) {
							utils.success("删除成功");
							_this.serviceRefresh();
						}, function (msg) {
							utils.alert(msg);
						});
					});
				},
				actionDelete: function (item) {
					var _this = this;
					utils.confirm('确定要删除功能【' + item.Name +'】？', function () {
						utils.ajaxPost('@(Url.Action("Delete","Sys_ModuleAction"))', { id: item.ID }, function (resp) {
							utils.success("删除成功");
							_this.actionRefresh();
						}, function (msg) {
							utils.alert(msg);
						});
					});
				},
				moduleBatchDelete: function () {
					var selected = this.moduleData.list.filter(function (item) {
						return item.CheckedState;
					});
					var ids = selected.map(function (item) {
						return item.ID;
					});
					if (!ids||ids.length == 0) {
						utils.alert('请先选择要删除的模块');
						return;
					}
					var _this = this;
					utils.confirm('确定要删除所选择的模块？', function () {
						utils.ajaxPost('@(Url.Action("BatchDelete", "Sys_Module"))',  ids , function (resp) {
							utils.success("删除成功");
							_this.moduleRefresh();
						}, function (msg) {
							utils.alert(msg);
						});
					});
				},
				serviceBatchDelete: function () {
					var selected = this.serviceData.list.filter(function (item) {
						return item.CheckedState;
					});
					var ids = selected.map(function (item) {
						return item.ID;
					});
					if (!ids||ids.length == 0) {
						utils.alert('请先选择要删除的菜单');
						return;
					}
					var _this = this;
					utils.confirm('确定要删除所选择的菜单？', function () {
						utils.ajaxPost('@(Url.Action("BatchDelete", "Sys_ModuleService"))',  ids , function (resp) {
							utils.success("删除成功");
							_this.serviceRefresh();
						}, function (msg) {
							utils.alert(msg);
						});
					});
				},
				actionBatchDelete: function () {
					var selected = this.actionData.list.filter(function (item) {
						return item.CheckedState;
					});
					var ids = selected.map(function (item) {
						return item.ID;
					});
					if (!ids||ids.length == 0) {
						utils.alert('请先选择要删除的功能');
						return;
					}
					var _this = this;
					utils.confirm('确定要删除所选择的功能？', function () {
						utils.ajaxPost('@(Url.Action("BatchDelete", "Sys_ModuleAction"))',  ids , function (resp) {
							utils.success("删除成功");
							_this.actionRefresh();
						}, function (msg) {
							utils.alert(msg);
						});
					});
				},
				saveModule: function () {
					var _this = this;
					utils.ajaxPost('@(Url.Action("Save", "Sys_Module"))', _this.currentModule, function (resp) {
						popClose();
						_this.moduleRefresh();
					}, function (msg) {
						utils.alert(msg);
					});
				},
				saveService: function () {
					var _this = this;
					utils.ajaxPost('@(Url.Action("Save", "Sys_ModuleService"))', _this.currentService, function (resp) {
						popClose();
						_this.serviceRefresh();
					}, function (msg) {
						utils.alert(msg);
					});
				},
				saveAction: function () {
					var _this = this;
					utils.ajaxPost('@(Url.Action("Save", "Sys_ModuleAction"))', _this.currentAction, function (resp) {
						popClose();
						_this.actionRefresh();
					}, function (msg) {
						utils.alert(msg);
					});
				},
				exportSql: function () {
					utils.ajaxExport('@(Url.Action("ExportSql", "Sys_Module"))', {});
				},
				batchAddAction: function (item) {
					batchAddAction(item);
				}
			},
			computed: {
				moduleList: function () {
					var _this = this;
					return this.moduleData.list.map(function (item) {
						return Object.assign({}, item, {
							//StateNow: _this.$options.filters.formatState(item.StateNow),
						});
					});
				},
				serviceList: function () {
					var _this = this;
					return this.serviceData.list.map(function (item) {
						return Object.assign({}, item, {
							//StateNow: _this.$options.filters.formatState(item.StateNow),
						});
					});
				},
				actionList: function () {
					var _this = this;
					return this.actionData.list.map(function (item) {
						return Object.assign({}, item, {
							//StateNow: _this.$options.filters.formatState(item.StateNow),
						});
					});
				},
				currentM: function () {
					var currentM = null;
					var i;
					var j;
					for (i = 0; i < this.global.modules.length; i++) {
						for (j = 0; j < this.global.modules[i].Services.length; j++) {
							if (this.serviceCode == this.global.modules[i].Services[j].Code) {
								currentM = this.global.modules[i];
								break;
							}
						}
					}
					return currentM;
				},
				currentS: function () {
					var currentS = null;
					var i;
					var j;
					for (i = 0; i < this.global.modules.length; i++) {
						for (j = 0; j < this.global.modules[i].Services.length; j++) {
							if (this.serviceCode == this.global.modules[i].Services[j].Code) {
								currentS = this.global.modules[i].Services[j];
								break;
							}
						}
					}
					return currentS;
				}
			},
			filters: {
				//formatState: function (val) {
				//	return utils.formatEnum(val, pageEnumData.state);
				//}
			}
		});
	</script>
	@*列表相关结束*@
	@*区域相关开始*@
	<script type="text/javascript">
		var popLayerIndex;
		function popOpen(id,width) {
			popLayerIndex=layer.open({
				type: 1,
				title: false,
				closeBtn: 0,
				area: width||'520px',
				skin: 'layui-layer-nobg', //没有背景色
				shadeClose: false,
				content: $(id)
			});
		}

		function popClose() {
			layer.close(popLayerIndex|| layer.index);
		}

		function moduleAdd() {
			utils.ajaxPost('@(Url.Action("GenCode", "Sys_Module"))',null, function (resp) {
				$('#moduleEditDiv').find('.windLayerHeading').html('新增模块信息');
				pageApp.currentModule = {
					ID: 0,
					Sort: 0,
					Icon: 'icon-',
					Code: resp.data,
					Visible:true,
				};
				popOpen('#moduleEditDiv','520px');
			}, function (msg) {
				utils.alert(msg);
			});
		}

		function serviceAdd() {
			if (!pageApp.currentModule || !pageApp.currentModule.ID) {
				utils.alert('请先选中要添加菜单的模块');
				return;
			}
			utils.ajaxPost('@(Url.Action("GenCode", "Sys_ModuleService"))',null, function (resp) {
				$('#serviceEditDiv').find('.windLayerHeading').html('新增菜单信息');
				pageApp.currentService = {
					ID: 0,
					Sort: 0,
					ModuleID: pageApp.currentModule.ID,
					ModuleName: pageApp.currentModule.Name,
					Code:resp.data,
					Visible:true,
				};
				popOpen('#serviceEditDiv','520px');
			}, function (msg) {
				utils.alert(msg);
			});
		}

		function actionAdd() {
			if (!pageApp.currentService || !pageApp.currentService.ID) {
				utils.alert('请先选中要添加功能的菜单');
				return;
			}
			utils.ajaxPost('@(Url.Action("GenCode", "Sys_ModuleAction"))',null, function (resp) {
				$('#actionEditDiv').find('.windLayerHeading').html('新增功能信息');
				pageApp.currentAction = {
					ID: 0,
					Sort: 0,
					Code:resp.data,
					ServiceID:pageApp.currentService.ID,
					ServiceName:pageApp.currentService.Name,
					Visible:true,
				};
				popOpen('#actionEditDiv','520px');
			}, function (msg) {
				utils.alert(msg);
			});
		}

		function moduleEdit(item) {
			if (!item) {
				return;
			}
			utils.ajaxPost('@(Url.Action("ViewJson", "Sys_Module"))', { id: item.ID }, function (resp) {
				pageApp.currentModule = resp.data;
				$('#moduleEditDiv').find('.windLayerHeading').html('修改模块信息');
				popOpen('#moduleEditDiv','520px');
			}, function (msg) {
				utils.alert(msg);
			});
		}

		function serviceEdit(item) {
			if (!item) {
				return;
			}
			utils.ajaxPost('@(Url.Action("ViewJson", "Sys_ModuleService"))', { id: item.ID }, function (resp) {
				pageApp.currentService = resp.data;
				$('#serviceEditDiv').find('.windLayerHeading').html('修改菜单信息');
				popOpen('#serviceEditDiv','520px');
			}, function (msg) {
				utils.alert(msg);
			});
		}

		function actionEdit(item) {
			if (!item) {
				return;
			}
			utils.ajaxPost('@(Url.Action("ViewJson", "Sys_ModuleAction"))', { id: item.ID }, function (resp) {
				pageApp.currentAction = resp.data;
				$('#actionEditDiv').find('.windLayerHeading').html('修改功能信息');
				popOpen('#actionEditDiv','520px');
			}, function (msg) {
				utils.alert(msg);
			});
		}

		function openPopIcon(callback,target) {
			utils.layerPop('@(Url.Action("Icons","Sys"))?callback='+callback, '400px', '450px',$(target).prev('input'));
		}

		function popModuleIconCallback(ret) {
			pageApp.currentModule= Object.assign({}, pageApp.currentModule, {
				Icon:ret
			});
		}

		function popModuleIconClear() {
			pageApp.currentModule= Object.assign({}, pageApp.currentModule, {
				Icon:''
			});
		}

		function popServiceIconCallback(ret) {
			pageApp.currentService = Object.assign({}, pageApp.currentService, {
				Icon:ret
			});
		}

		function popServiceIconClear() {
			pageApp.currentService = Object.assign({}, pageApp.currentService, {
				Icon:''
			});
		}

		function popActionIconCallback(ret) {
			pageApp.currentAction= Object.assign({}, pageApp.currentAction, {
				Icon:ret
			});
		}

		function popActionIconClear(ret) {
			pageApp.currentAction= Object.assign({}, pageApp.currentAction, {
				Icon:''
			});
		}

		function batchAddAction(item) {
			utils.ajaxPost('@(Url.Action("GenCode", "Sys_ModuleAction"))',null, function (resp) {
				pageApp.currentAction = {
					ID: 0,
					Sort: 0,
					Code:resp.data,
					ServiceID:pageApp.currentService.ID,
					ServiceName:pageApp.currentService.Name,
					Visible:true,
				};
				popOpen('#batchAddActionDiv','520px');
			}, function (msg) {
				utils.alert(msg);
			});
		}

		$(document).ready(function () {
			$("#moduleEditFrm").validationEngine({
				scroll: false,
				validateNonVisibleFields: false,
				autoHidePrompt: true,
				promptPosition:'topLeft',
				showOneMessage: true,
				ajaxFormValidationMethod: 'post',
				onValidationComplete: function (form, status) {
					if (!status) {
						return;
					}
					pageApp.saveModule();
				}
			});
			$("#serviceEditFrm").validationEngine({
				scroll: false,
				validateNonVisibleFields: false,
				autoHidePrompt: true,
				promptPosition:'topLeft',
				showOneMessage: true,
				ajaxFormValidationMethod: 'post',
				onValidationComplete: function (form, status) {
					if (!status) {
						return;
					}
					pageApp.saveService();
				}
			});
			$("#actionEditFrm").validationEngine({
				scroll: false,
				validateNonVisibleFields: false,
				autoHidePrompt: true,
				promptPosition:'topLeft',
				showOneMessage: true,
				ajaxFormValidationMethod: 'post',
				onValidationComplete: function (form, status) {
					if (!status) {
						return;
					}
					pageApp.saveAction();
				}
			});
		});

		function initSortable(tblID, opts) {
			var options = Object.assign({}, {
				draggable: "tr.sortable-item",
				ghostClass: "sortable-placeholder",
			}, opts);
			$(tblID + ' tbody').sortable('destroy');
			$(tblID + ' tbody').sortable(options);
		}

		function initSortableModule() {
			initSortable("#tblModuleList", {
				onEnd: function (evt) {
					var ids = [];
					$('#tblModuleList').find('tr.sortable-item').each(function (idx,elem) {
						ids.push(elem.dataset.rid);
					});
					if (ids.length > 0) {
						utils.ajaxPost('@(Url.Action("SaveSort", "Sys_Module"))', ids, function (resp) {
							pageApp.moduleRefresh();
						}, function (msg) {
							utils.alert(msg);
						});
					}
				},
			});
		}

		function initSortableService() {
			initSortable("#tblServiceList",{
				onEnd: function (evt) {
					var ids = [];
					$('#tblServiceList').find('tr.sortable-item').each(function (idx,elem) {
						ids.push(elem.dataset.rid);
					});
					if (ids.length > 0) {
						utils.ajaxPost('@(Url.Action("SaveSort", "Sys_ModuleService"))', ids, function (resp) {
							pageApp.serviceRefresh();
						}, function (msg) {
							utils.alert(msg);
						});
					}
				},
			});
		}

		function initSortableAction() {
			initSortable("#tblActionList",{
				onEnd: function (evt) {
					var ids = [];
					$('#tblActionList').find('tr.sortable-item').each(function (idx,elem) {
						ids.push(elem.dataset.rid);
					});
					if (ids.length > 0) {
						utils.ajaxPost('@(Url.Action("SaveSort", "Sys_ModuleAction"))', ids, function (resp) {
							pageApp.actionRefresh();
						}, function (msg) {
							utils.alert(msg);
						});
					}
				},
			});
		}
	</script>
	@*区域相关结束*@
}